package cn.dgut.training.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang.StringUtils;

import java.time.LocalDateTime;

@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="Admin对象", description="管理员表")
public class Admin extends BaseEntity {

    private static final long serialVersionUID = 1L;


    @ApiModelProperty(value = "管理员名称")
    private String username;

    @ApiModelProperty(value = "管理员密码")
    private String password;

    @ApiModelProperty(value = "最近一次登录IP地址")
    private String lastLoginIp;

    @ApiModelProperty(value = "最近一次登录时间")
    private LocalDateTime lastLoginTime;

    @ApiModelProperty(value = "头像图片")
    private String avatar;

    @ApiModelProperty(value = "角色列表")
    private String roleIds;

    

    public Integer[] getArrRoleIds(){

            String[] strArr = roleIds.split("x");
            Integer[] rs = new Integer[strArr.length];
            if(StringUtils.isBlank(strArr[0])) return null;
            for (int a = 0; a < strArr.length; a++) {
                rs[a] = Integer.valueOf(strArr[a]);
            }
            return rs;

    }


}
